#include<iostream>
#include<cstdio>
#include<string>
#include<unistd.h>
#include<ctime>
#include<pthread.h>
using namespace std;
int g_val = 100;
void* Routine(void* args)
{
	int cnt = 5;
	while(cnt)
	{
		cout << "new thread g_val: " <<g_val << "  &g_val:" << &g_val << endl;
		sleep(1);
		g_val++;
		cnt--;
	}
	return ((void*)10);
}
int main()
{
	pthread_t tid;
	pthread_create(&tid,nullptr,Routine,nullptr);
	int r = 0;
	while(true)
	{
		cout << "main_thread g_val: " << g_val << " &g_val: " << &g_val << endl;
		sleep(1);
		r++;
		if(r == 5)
			break;
	}
	int ret = pthread_join(tid,nullptr);
	cout <<"main thread ret: " << ret << endl;
	return 0;
}
